var mongoose = require('mongoose')
//连接数据库
mongoose.connect('mongodb://localhost/playground',{useNewUrlParser:true}).then(()=>{
    console.log("連接成功");
}).catch((err)=>{
    console.log("連接失敗");
})
var Schema = mongoose.Schema
//创建文档结构
var userSchema = new Schema({
    name: String,
    age: Number,
    email:String,
    password:String,
    hobbies:[String]
  });
  //将文档结构发布为模型  第一个参数为集合名称,User会转成users
  var User = mongoose.model('User',userSchema)
  //返回所有
//   User.find().then(result =>{
//     console.log('result :>> ', result);
// })

  User.find({_id:'5c09f236aeb04b22f8460967'}).then(result =>{
      console.log('result :>> ', result);
  })




